#include "prateleira2joshua.h"
#include <GL/glu.h>
#include "gllib/Objects.h"

void Prateleira2Joshua::draw()
{
    glEnable(GL_COLOR_MATERIAL);
    glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);

    float mat_specular[] = {0.7, 0.7, 0.7, 1.0};
    float mat_diffuse[] = {1.0, 1.0, 1.0, 0.3};
    float shininess = 20;

    glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
    glMaterialf(GL_FRONT, GL_SHININESS, shininess);
    glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse);

    glPushMatrix();
    desenharPrateleira();

    glPopMatrix();

    glDisable(GL_COLOR_MATERIAL);
}

void Prateleira2Joshua::desenharPrateleira(){
    glColor3f(1.0,0.5,0.0);
    glPushMatrix();
    glScalef(2.5, 0.05,1.0);
    gllibCube(1.0);
    glPopMatrix();

    glPushMatrix();
    glTranslatef(-1.0,0.0,-0.5);
    desenharPe();
    glPopMatrix();

    glPushMatrix();
    glTranslatef(1.0,0.0,-0.5);
    desenharPe();
    glPopMatrix();
}


void Prateleira2Joshua::desenharPe(){
    glPushMatrix();

    glColor3f(0.46,0.29,0.0);
    glBegin(GL_TRIANGLES);
        glVertex3f(0.0,0.0,0.0);
        glVertex3f(0.0,-0.5,0.0);
        glVertex3f(0.0,0.0,0.5);
    glEnd();

    glBegin(GL_QUAD_STRIP);
        glVertex3f(0.1,0.0,0.0);
        glVertex3f(0.0,0.0,0.0);
        glVertex3f(0.1,0.0,0.5);
        glVertex3f(0.0,0.0,0.5);

        glVertex3f(0.1,-0.5,0.0);
        glVertex3f(0.0,-0.5,0.0);

        glVertex3f(0.1,0.0,0.0);
        glVertex3f(0.0,0.0,0.0);
    glEnd();

    glColor3f(0.0,0.0,1.0);
    glBegin(GL_TRIANGLES);
        glVertex3f(0.1,0.0,0.0);
        glVertex3f(0.1,0.0,0.5);
        glVertex3f(0.1,-0.5,0.0);
    glEnd();

    glPopMatrix();
}
